<template>
  <figure>
    <img :src="src" :alt="alt" />
    <figcaption>
      <h4><slot name="title"></slot></h4>
      <p><slot name="cont"></slot></p>
    </figcaption>
  </figure>
</template>

<script>
export default {
  props: {
    src: String,
    alt: String,
  },
};
</script>

<style lang="less" scoped>
@keyframes float {
  from {
    transform: translateX(-50%) translateY(0px);
  }
  to {
    transform: translateX(-50%) translateY(10px);
  }
}

figure {
  img {
    width: 100%;
  }
  figcaption {
    position: absolute;
    left: 50%;
    bottom: -20%;
    transform: translateX(-50%);
    width: 80%;
    padding: 30px 40px;
    box-sizing: border-box;
    text-align: center;
    background-color: #f9f9f9;
    &::after {
      content: "";
      display: block;
      width: calc(100% + 15px);
      height: calc(100% + 15px);
      border: 1px solid #bfbfbf;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      z-index: -1;
    }
    h4 {
      font-size: 24px;
      &::after {
        content: "";
        display: block;
        margin: 15px auto 20px;
        width: 1em;
        height: 5px;
        background-color: #ff701a;
      }
    }
    p {
      font-size: 14px;
    }
  }
  &:hover figcaption {
    animation: float 1s ease-in-out infinite alternate;
  }
}
</style>